Write to file
Places data in a file that has been opened with the open file command.Syntax: write to {file | stdout} { | EOF | end} Examples: write "test" to file "test.txt" write linefeed to stdout write "Hello" & return to stdout write "ATZ" to file "modem:" mouseUp local tFile put specialFolderPath("desktop") & "/test.txt" into tFile open file tFile for text write Use the write to file command to change the contents of a file. If the file was opened in write mode, the write to file command completely replaces the file contents from the start. For example, if the file originally contains "ABC", and you write "1" to it, after the write to file command is executed the file contains "1". If the file was opened in update mode, if you write less data to the file than it already contains, the write to file command does not remove characters from it. For example, if the file originally contains "ABC", and you write "1" to it, after the write to file command is executed the file contains "1BC". If the file was opened in append mode, the write begins at the end of the file. After writing, you must close the file with the close filecommand. The write to stdout form writes to the standard output (on Unix systems). The standard output is always open, so you can write to it without first opening it. *Tip:* As an alternative to the open file and write to file commands, you can also use the URLkeyword with the putcommand to change the contents of a file. Parameters: *value (string): * pathName:The pathName specifies the name and location of the file you want towrite to. It must be the same as the path you used with the open filecommand. The pathName is case-sensitive, even on platforms where filenames are not case-sensitive. If you specify the name of a serial porton Mac OS or Windows systems, LiveCode writes to the specified port. Thenames of serial ports end in a colon (:). *start (enum): The start specifies the character or byte position in the file where youwant to begin writing. A positive number begins start characters afterthe beginning of the file; a negative number begins start charactersbefore the end of the file. If you specify either of the synonyms EOF orend, the write begins after the last character in the file. If you don'tspecify a start, the write begins: *- at the position determined by the seek command, or - if you haven't used the seek command, wherever the last read from file or write to file command to the file left off, or- if you haven't accessed the file with read from file or write to file since it was opened, after the last character (if the file was opened in append mode) or at the first character (if the file was opened in any other mode). * The result:The file to write to must be opened first with the open file command,and the mode the file was opened in must be write, append, or update.If the file is not open or is open read-only, the result function isset to "File is not open for write.". See also: write to driver (command),open file command (command),putcommand (command),close filecommand (command),result (function), Category: file system